package com.wk.service.impl;

import com.wk.entity.MailBean;
import com.wk.service.MailService;
import com.wk.util.MailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 王珂
 * @date 2020/7/21 0:04
 */
@Service
@Slf4j
public class MailServiceImpl implements MailService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Autowired
    private MailUtil mailUtil;

    private static int count=0;

    @Override
    public void sendMsgToMq(String msg) {
        rabbitTemplate.convertAndSend("hello",msg);
    }

//    @RabbitListener(queuesToDeclare = @Queue("hello"))
//    public void sendEmail(String msg){
//        MailBean mailBean = new MailBean();
//        mailBean.setSubject("极限云上线测试");
//        mailBean.setText(msg);
//        //发送邮件
//        mailUtil.sendMail();
//        log.info("发送邮件"+count++);
//    }
}
